from django.db import models

from sportsground.utils.baseModels import BaseModels


class VenueSport(BaseModels):
    class Meta():
        db_table = 'venue_sport'
        verbose_name = '运动类型'
        verbose_name_plural = verbose_name

    name = models.CharField(max_length=20, verbose_name="名称")
    venue = models.ForeignKey(to="Venue.Venue", on_delete=models.CASCADE, verbose_name="对应馆场")

    @classmethod
    def create(cls, name, venue):
        """ 创建运动类型 """
        sport = cls(name=name, venue=venue)
        sport.save()
        return sport

    def Info(self):
        return {
            "id": self.id,
            "name": self.name,
        }
